package com.xb.loan.util.binaryConvert.parse.num;


import com.xb.loan.util.binaryConvert.ConvertUtil;
import com.xb.loan.util.binaryConvert.config.ParseConfig;
import com.xb.loan.util.binaryConvert.parse.ParseAble;
import com.xb.loan.util.binaryConvert.parse.ParsePointer;

public class ShortParser implements ParseAble<Short> {

	@Override
	public Short convert(byte[] b, ParsePointer pointer, Class<?> clazz, ParseConfig config) {
		
		short s = ConvertUtil.readShort(b, pointer.getPointer());
		// 指针后移2个单位
		pointer.move(2);
		
		return s;
	}

	@Override
	public byte[] format(Short obj,ParseConfig config) {
		
		byte[] src = new byte[2];
		
		ConvertUtil.putShort(src, 0, obj);
		
		return src;
	}

}
